package com.dayatang.koala.support;

import java.io.InputStream;
import java.util.Map;

import javax.rules.admin.LocalRuleExecutionSetProvider;
import javax.rules.admin.RuleExecutionSet;

import com.dayatang.koala.service.UnSupportRuleFormatException;

public class RuleExecutionSetInputStreamCreator implements
		RuleExecutionSetCreator {

	public RuleExecutionSet createRuleExecutionSet(Object ruleSource,
			Map ruleProperty,
			LocalRuleExecutionSetProvider ruleExecutionSetProvider)
			throws RuntimeException {

		try {
			if (ruleSource instanceof InputStream) {
				return ruleExecutionSetProvider.createRuleExecutionSet(
						(InputStream) ruleSource, ruleProperty);
			} else {
				throw new UnSupportRuleFormatException();
			}
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		}

	}

}
